package cn.easybuy.web.pre;

import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.easybuy.entity.News;
import cn.easybuy.entity.ProductCategory;
import cn.easybuy.service.news.NewsService;
import cn.easybuy.service.news.NewsServiceImpl;
import cn.easybuy.service.proudct.ProductCategoryService;
import cn.easybuy.service.proudct.ProductCategoryServiceImpl;
import cn.easybuy.utils.ProductCategoryVo;
import cn.easybuy.web.AbstractServlet;

@WebServlet(urlPatterns= {"/HomeServlet"},name="HomeServlet")
public class HomeServlet extends AbstractServlet {
	private ProductCategoryService pcService;
	private NewsService newsService;
	private static Logger logger = Logger.getLogger(HomeServlet.class.getName());

	@Override
	public Class getServletClass() {
		// TODO Auto-generated method stub
		return HomeServlet.class;
	}

	
	public void init() throws ServletException {
		pcService = new ProductCategoryServiceImpl();
		newsService = new NewsServiceImpl();
	}
	
	public String index(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<ProductCategoryVo> pcList = pcService.queryAllProductCategory();
		List<News> newsList = newsService.queryAllnews();
		request.setAttribute("pcList", pcList);
		request.setAttribute("newsList", newsList);
		return "/pre/index";
	}


}
